DragTarget

Kind of class:class
Inherits from:UIComponent < MovieClip
Known subclasses:
Classpath:gfx.controls.DragTarget
File last modified:Tuesday, 29 June 2010, 09:03:27
Acts as a target for drag operations initiated with DragManager. The drag target will hide itself until a drag operation begins with a data object that it can accept, at which point it will show itself.

While the usefulness of this class is limited, it provides a simple example for working with DragManager, and is the basis for the InventorySlot and ItemSlot components.
Component metadata:
    InspectableList
    "_dragAcceptTypes"
    "disabled"
    "enableInitCallback"
    "visible"

    Summary


    Constructor
    Class methods
    Class methods inherited from UIComponent
    Event handlers
    • allowDrop
      • Returns true if the DragTarget instance will accept the specified data object.

    Constructor

    DragTarget

    function DragTarget (
    )

    The constructor is called when a DragTarget is instantiated on stage or by using attachMovie() in ActionScript. This component can not be instantiated using new syntax. When creating new components that extend DragTarget, ensure that a super() call is made first in the constructor.

    Instance properties

    dragAcceptTypes

    dragAcceptTypes:Array
    (read,write)

    Indicates the types of data this DragTarget will accept. These strings are matched against the "type" property of the data object passed to allowDrop. Setting dragAcceptTypes to ["*"] or null will cause it to accept all types.
    Parameters:
    types:
    An array of strings that will be matched against the data object "type" property.

    Instance methods

    acceptDrop

    function acceptDrop (
    data:Object) : Void

    The DragManager has dropped data on to this component. It is public so that is can be externally overridden. See ItemSlot.
    Parameters:
    data:
    The data that is being dropped on the component.

    Event handlers

    allowDrop

    function allowDrop (
    data:Object) : Boolean

    Returns true if the DragTarget instance will accept the specified data object. In this case it matches the data object's "type" property against the types specified in dragAcceptTypes, but this method can easily be overridden in subclasses to provide more advanced filtering.
    Parameters:
    data:
    The data object to check.